package com.xbongbong.pro.enums.fund.enums;

import com.xbongbong.i18n.util.I18nMessageUtil;
import lombok.Getter;

import java.util.Arrays;
import java.util.List;
import java.util.Objects;

/**
 * @Description  经销商回款单支付方式
 * @author: zcp
 */
@Getter
public enum PayMethodDistributorEnum {
    //预收款账户：prepayment
    PREPAYMENT("1", "prepayment", "enum.payMethodDistributor.name.prepayment", "enum.payMethodDistributor.distributorName.prepayment"),

    //微信：weChat
    WECHAT("2", "weChat", "enum.payMethodDistributor.name.wechat", "enum.payMethodDistributor.name.wechat"),

    //支付宝：alipay
    ALIPAY("3", "alipay", "enum.payMethodDistributor.name.alipay", "enum.payMethodDistributor.name.alipay"),

    //银联：unionPay
    UNION_PAY("4", "unionPay", "enum.payMethodDistributor.name.union_pay", "enum.payMethodDistributor.name.union_pay"),

    //线下打款：offline
    OFFLINE("5", "offline", "enum.payMethodDistributor.name.offline", "enum.payMethodDistributor.name.offline"),

    //代客操作：proOperate，即在Pro内操作
    PRO_OPERATE("6", "proOperate", "enum.payMethodDistributor.name.pro_operate", "enum.payMethodDistributor.distributorName.pro_operate"),

    //信用支付：credit
    CREDIT("7", "credit", "enum.payMethodDistributor.name.credit", "enum.payMethodDistributor.name.credit"),
    ;

    /**
     * 支付-标识
     */
    private String code;

    /**
     * 支付-别名
     */
    private String alias;

    /**
     * 支付-名称
     */
    private String name;
    /**
     * 支付-经销商端名称
     */
    private String distributorName;

    PayMethodDistributorEnum(String code, String alias, String name, String distributorName) {
        this.code = code;
        this.alias = alias;
        this.name = name;
        this.distributorName = distributorName;
    }

    public static PayMethodDistributorEnum getByAlias(String alias) {
        for (PayMethodDistributorEnum payMethodEnum : values()) {
            if (Objects.equals(payMethodEnum.getAlias(),alias)) {
                return payMethodEnum;
            }
        }
        return null;
    }
    public static String getNameByCode(String code) {
        for (PayMethodDistributorEnum payMethodEnum : values()) {
            if (Objects.equals(payMethodEnum.getCode(),code)) {
                return payMethodEnum.getName();
            }
        }
        return "";
    }

    /**
     * 强制进入审批的支付方式
     * @return java.util.List<java.lang.Object> 审批条件ConditionsEntityExt.value字段需要的是List<Object>
     * @author zcp
     * @since v1.0
     * @version v1.0
     */
    public static List<Object> mustIntoProcess(){
        return Arrays.asList(OFFLINE.code, PRO_OPERATE.code);
    }

    /**
     * 获取订单那边的支付方式汇总
     *
     * @return
     */
    public static List<PayMethodDistributorEnum> orderPayMethodList() {
        return Arrays.asList(PayMethodDistributorEnum.PREPAYMENT, PayMethodDistributorEnum.WECHAT, PayMethodDistributorEnum.ALIPAY,
                PayMethodDistributorEnum.UNION_PAY, PayMethodDistributorEnum.OFFLINE, PayMethodDistributorEnum.CREDIT);
    }

    /**
     * 获取待付款那边的支付方式汇总
     *
     * @return
     */
    public static List<PayMethodDistributorEnum> paymentMethodList() {
        return Arrays.asList(PayMethodDistributorEnum.PREPAYMENT, PayMethodDistributorEnum.WECHAT, PayMethodDistributorEnum.ALIPAY,
                PayMethodDistributorEnum.UNION_PAY, PayMethodDistributorEnum.OFFLINE);
    }

    /**
     * 信用额度的支付方式汇总
     *
     * @return
     */
    public static List<PayMethodDistributorEnum> creditMethodList() {
        return Arrays.asList(PayMethodDistributorEnum.PREPAYMENT, PayMethodDistributorEnum.WECHAT, PayMethodDistributorEnum.ALIPAY,
                PayMethodDistributorEnum.UNION_PAY, PayMethodDistributorEnum.OFFLINE);
    }

    /**
     * 获取充值那边的支付方式汇总
     *
     * @return
     */
    public static List<PayMethodDistributorEnum> rechargeMethodList() {
        return Arrays.asList(PayMethodDistributorEnum.WECHAT, PayMethodDistributorEnum.ALIPAY,
                PayMethodDistributorEnum.UNION_PAY, PayMethodDistributorEnum.OFFLINE);
    }

    /**
     * 支付方式中属于线上支付的支付方式
     *
     * @return
     */
    public static List<String> onlinePayList() {
        return Arrays.asList(PayMethodDistributorEnum.WECHAT.getAlias(), PayMethodDistributorEnum.ALIPAY.getAlias(),
                PayMethodDistributorEnum.UNION_PAY.getAlias());
    }

    public String getName() {
        return I18nMessageUtil.getMessage(name);
    }

    public String getDistributorName() {
        return I18nMessageUtil.getMessage(distributorName);
    }
}